package com.heima.leadnews.admin.controller.v1;



import com.heima.common.exception.CustomException;
import com.heima.leadnews.admin.service.AdChannelService;
import com.heima.model.admin.dto.ChannelDto;
import com.heima.model.admin.pojo.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhuangzhiwen
 */
@RestController
@RequestMapping(("/api/v1/channel"))
@Api(value = "频道列表", description = "分页频道列表")
public class AdChannelController {

    @Autowired
    AdChannelService channelService;

    @ApiOperation("分页查询列表")
    @PostMapping("/list")
    public ResponseResult listChannel(@RequestBody ChannelDto dto){
        return channelService.listChannel(dto);
    }

    @ApiOperation("频道新增")
    @PostMapping("/save")
    public  ResponseResult insert(@RequestBody AdChannel adChannel){
        return channelService.insert(adChannel);
    }

    @ApiOperation("频道修改")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return channelService.update(adChannel);
    }

    @ApiOperation("频道删除")
    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable("id") Integer id){
        return channelService.del(id);
    }


}
